/*
 *  SyncIT , easy synchronization of files between computers and devices.
 *  Copyright (C) 2011  Christian Masus <cmasus(at)gmail.com>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version. If redistributing and/or modifying
 *  this file, this notice must be included in the redistributed or
 *  modified copy.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package config.items;

/**
 * Defines the configuration items related to the log system,
 * stored under "log/".
 * @author Christian Masus
 *
 */
public class LogItems {

	// Default values
	private final int     DEFAULT_CURRENT_FILE_NUMBER = 1;
	private final int     DEFAULT_MAX_LOG_FILES       = 9;
	private final int     DEFAULT_MAX_FILE_SIZE       = 1024 * 1024; // 1 MB

	// Configuration
	private int currentFileNumber;
	private int maxLogFiles;
	private int maxFileSize;


	public LogItems() {
		loadDefaultValues();
	}


	public int getCurrentFileNumber() {
		return currentFileNumber;
	}
	public void setCurrentFileNumber(int currentFileNumber) {
		this.currentFileNumber = currentFileNumber;
	}
	public void setCurrentFileNumber(String currentFileNumber) {
		this.currentFileNumber = new Integer(currentFileNumber);
	}

	public int getMaxLogFiles() {
		return maxLogFiles;
	}
	public void setMaxLogFiles(int maxLogFiles) {
		this.maxLogFiles = maxLogFiles;
	}
	public void setMaxLogFiles(String maxLogFiles) {
		this.maxLogFiles = new Integer(maxLogFiles);
	}

	public int getMaxFileSize() {
		return maxFileSize;
	}
	public void setMaxFileSize(int maxFileSize) {
		this.maxFileSize = maxFileSize;
	}
	public void setMaxFileSize(String maxFileSize) {
		this.maxFileSize = new Integer(maxFileSize);
	}



	public void loadDefaultValues() {
		currentFileNumber = DEFAULT_CURRENT_FILE_NUMBER;
		maxLogFiles       = DEFAULT_MAX_LOG_FILES;
		maxFileSize       = DEFAULT_MAX_FILE_SIZE;
	}

	public String[][] getTagValuePair() {
		String[][] ret = {
				{"CurrentFileNumber", new Integer(currentFileNumber).toString()},
				{"MaxLogFiles",       new Integer(maxLogFiles).toString()},
				{"MaxFileSize",       new Integer(maxFileSize).toString()}
		};
		return ret;
	}

	public String toString() {
		String ret = "";
		String[][] tagValuePair = getTagValuePair();
		for(int row = 0; row < tagValuePair.length; row++) {
			ret += tagValuePair[row][0] + " = " + tagValuePair[row][1] + "\n";
		}
		return ret;
	}
}
